﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string userName2 = "";
            string password2 = "";
            //第一种
            string userName1 = Request.Form["UserName"];
            string password1 = Request.Form["Password"];

            //第二种
            if (PreviousPage != null)
            {
                TextBox userNameBox = (TextBox)PreviousPage.FindControl("UserName");
                TextBox passwordBox = (TextBox)PreviousPage.FindControl("Password");
                if (userNameBox != null)
                {
                    userName2 = userNameBox.Text;
                }
                if (passwordBox != null)
                {
                    password2 = passwordBox.Text;
                }
            }


            //第三种
            string userName3 = Request.Params["UserName"];
            string password3 = Request.Params["Password"];


            //第四种
            string userName4 = Request.QueryString["n"];
            string password4 = Request.QueryString["p"];
            string userName5 = Request.Params["n"];
            string password5 = Request.Params["p"];

            Response.Write($"Form  ==>  你的账号是：{userName1}，你的密码是{password1} <br/><br/><br/>");
            Response.Write($"PreviousPage  ==>  你的账号是：{userName2}，你的密码是{password2}<br/><br/><br/>");
            Response.Write($"Params  ==>  你的账号是：{userName3}，你的密码是{password3} <br/><br/><br/>");
            Response.Write($"QueryString  ==>  你的账号是：{userName4}，你的密码是{password4} <br/><br/><br/>");
            Response.Write($"Params  ==>  你的账号是：{userName5}，你的密码是{password5} <br/><br/><br/><br/><br/><br/>");

        }
    }
}